import request from "./request";

//登录
export async function login (param) {
  return await request({
    url: '/user/login',
    method: 'post',
    data:param
  })
}

//注册
export async function register (param) {
  return await request({
    url: '/user/register', 
    method: 'post',
    data:param
  })
}

//获取验证码
export async function getCode (param) {
  return await request({
    url: '/user/code',
    method: 'post',
    data:param
  })
}

//查询用户信息
export async function getUser (params) {
  return await request({
    url: '/user/'+params.userId,
    method: 'get',
    headers: {
      'Content-Type': 'application/json',
      'token': params.token 
    }
  })
}

//保存修改
export async function update (param,params) {
  return await request({
    url: '/user',
    method: 'put',
    data:param,
    headers: {
      'Content-Type': 'application/json',
      'token': params.token 
    }
  })
}

//修改密码
export async function updatePd (param,params) {
  return await request({
    url: '/user/upd',
    method: 'post',
    data:param,
    headers: {
      'Content-Type': 'application/json',
      'token': params.token 
    }
  })
}

//修改邮箱
export async function updateEm (param,params) {
  return await request({
    url: '/user/email',
    method: 'post',
    data:param,
    headers: {
      'Content-Type': 'application/json',
      'token': params.token 
    }
  })
}

//认证
export async function approve (param,params) {
  return await request({
    url: '/user/approve',
    method: 'post',
    data:param,
    headers: {
      'Content-Type': 'application/json',
      'token': params.token 
    }
  })
}